﻿@using KRM.Core.Library
@model KRM.Core.tblTicket
<form action="/Ticket/AddTaskFromTicket" id="frAddTask" method="POST" class="" style="margin: 0">
    @Html.ValidationSummary(true)
    <input type="hidden" name="AssignedByUser" id="UserID" value="@Users.Current(User.Identity.Name).UserID"/>
    <input type="hidden" name="ticketId" id="ticketId" value="@Model.TicketID"/>
    <input type="hidden" name="originalEmailID" id="originalEmailID" value="@Model.OriginalEmailID"/>
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
        <h4>Create Task</h4>
    </div>
    <div class="modal-body">
        <div id="msg-frAddTask">
        </div>
        <div class="row-fluid">
            <label class="span2 control-label">Task type</label>
            <div class="span10">
                @Html.DropDownList("TaskTypeID", null, new { @class = "input-block-level", @onchange = "gettitles(this.value)" })
            </div>
        </div>

        <div class="row-fluid">
            <label class="span2 control-label">Task title</label>
            <div class="span10">
                @Html.DropDownList("TaskTitleID", null, new { @class = "input-block-level", @onchange = "" })
            </div>
        </div>

        <div class="row-fluid">
            <label class="span2 control-label">Reason</label>
            <div class="span10">
                <select class="input-block-level" name="reason" id="ReasonID">
                    <option value="0">--Select a title--</option>
                    <option value="Customer Change Of Circumstances">Customer Change Of Circumstances</option>
                    <option value="Damaged">Damaged</option>
                    <option value="Incorrect">Incorrect</option>
                    <option value="Missing">Missing</option>
                    <option value="Other">Other</option>
                </select>
            </div>
        </div>

        <div class="row-fluid">
            <label class="span2 control-label">Description</label>
            <div class="span10">
                <textarea style="width: 96%;" rows="4" id="TaskDescription" name="TaskDescription">@ViewBag.Description 
                    </textarea>
            </div>
        </div>
        <div class="row-fluid">
            <label class="span2 control-label">Assign to user</label>
            <div class="span4">
                @Html.DropDownList("AssignedToUser", null, new { @class = "input-block-level", @onchange = "" })
            </div>
            <label class="span2 control-label">OrderRef</label>
            <div class="span4" id="groupOrderRef">
                <input type="text" id="TaskOrderRef" name="OrderRef" class="input-block-level" placeholder="Enter OrderRef" value="@ViewBag.OrderRef"
               title="" data-placement="top" data-original-title="Top Tooltip" onchange="CheckOrderRefExist(this.value)">
            </div>
        </div>
        <div class="row-fluid">
            <div class="span2">Completed</div>
            <div class="span4">
                <div id="datetimepicker3" class="input-append">
                    <input data-format="MM/dd/yyyy" type="text" name="CompleteByDate" value="@((Model.DateCompleted ?? DateTime.Now.AddHours(1)).ToString("MM/dd/yyyy"))" required="required" style="width:61%;"/>
                    <span class="add-on">
                        <i data-date-icon="icon-calendar" class="icon-calendar"></i>
                    </span>
                </div>
            </div>
            <div class="span1">Hrs:</div>
            <div class="span2">
                <select name="CompleteByHrs" class="input-block-level">
                    @{var currentHrs = (Model.DateCompleted ?? DateTime.Now).Hour;}
                    <option value="00">@currentHrs</option>
                    <option value="18"@(currentHrs == 18 ? "selected='selected'" : "")>18</option>
                    <option value="17"@(currentHrs == 17 ? "selected='selected'" : "")>17</option>
                    <option value="16"@(currentHrs == 16 ? "selected='selected'" : "")>16</option>
                    <option value="15"@(currentHrs == 15 ? "selected='selected'" : "")>15</option>
                    <option value="14"@(currentHrs == 14 ? "selected='selected'" : "")>14</option>
                    <option value="13"@(currentHrs == 13 ? "selected='selected'" : "")>13</option>
                    <option value="12"@(currentHrs == 12 ? "selected='selected'" : "")>12</option>
                    <option value="11"@(currentHrs == 11 ? "selected='selected'" : "")>11</option>
                    <option value="10"@(currentHrs == 10 ? "selected='selected'" : "")>10</option>
                    <option value="09"@(currentHrs == 9 ? "selected='selected'" : "")>9</option>
                    <option value="08"@(currentHrs == 8 ? "selected='selected'" : "")>8</option>
                </select>
            </div>
            <div class="span1">Mins:</div>
            <div class="span2">
                <select name="CompleteByMins" class="input-block-level">
                    @{var currentMins = (Model.DateCompleted ?? DateTime.Now).Minute;}
                    <option value="00"@(currentMins == 0 ? "selected='selected'" : "")>00</option>
                    <option value="15"@(currentMins == 15 ? "selected='selected'" : "")>15</option>
                    <option value="30"@(currentMins == 30 ? "selected='selected'" : "")>30</option>
                    <option value="45"@(currentMins == 45 ? "selected='selected'" : "")>45</option>
                </select>
            </div>
        </div>
        <div class="row-fluid">
            <label class="span2 control-label">Duration</label>
            <div class="span4">
                @Html.DropDownList("DurationID", null, new { @class = "input-block-level" })
            </div>
            <label class="span2 control-label">Priority</label>
            <div class="span4">
                @Html.DropDownList("PriorityID", null, new { @class = "input-block-level" })
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
        <button type="submit" id="btnAccept" class="btn btn-success">Create</button>
    </div>
</form>
